<template>
	<view>
		
		<block v-if="is_shensu!=2">
			<orderCommon
				:text="text" :order="order" :afterSalesRecord="afterSalesRecord3"
				:customStyle1="customStyle1" :customStyle11="customStyle11" 
				:customStyle2="customStyle2" :customStyle3="customStyle3">
			</orderCommon>
				
			<view style="margin-top: 10rpx;padding-bottom: 20rpx;width: 94%;margin-left: 3%;">
				<u-button v-if="is_shensu==1" @click="approve(1)" style="float: right;margin-right: 5rpx;" :custom-style="customStyle1" hover-class="none" :disabled="subDisabled" type="primary"
					>
					{{ $t('认可') }}
				</u-button>
				
				<!--点击申诉 打开cooperateApply页面 提交申诉-->
				<u-button @click="shensu()" style="float: right;margin-right: 15rpx;" :custom-style="customStyle11" hover-class="none" :disabled="subDisabled" type="primary"
					>
					{{ $t('申诉') }}
				</u-button>
				
				
				<u-button @click="communicates()" style="float: right;margin-right: 15rpx;" :custom-style="customStyle11" hover-class="none" :disabled="subDisabled" type="primary"
					>
					{{ $t('即时联系') }}
				</u-button>	
				<view style="clear: both;"></view>
			</view>
		</block>
		<block v-if="is_shensu==2">
			<cooperateApply v-if="loading" :text="text" :order="order" :customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :afterSalesRecord="afterSalesRecord2" :customStyle3="customStyle3" @change="shensu_action">
			</cooperateApply>
		</block>
		<view style="height: 50px;"></view>
			
	</view>
</template>

<script>
	import orderCommon from './orderCommon.vue';
	import cooperateApply from './cooperateApply.vue';
	
	
	
	import {
		ImageUrl,
		isVideo,
		time,createC2CConversation
	} from "@/common/public";
	export default {
		components:{
			orderCommon,cooperateApply
		},
		props:{
			order:{
				type:Object,
				default:{}
			},
			afterSalesRecord:{
				type:[Object,null],
				default:{}
			},
			text:{
				type:Object,
				default:{}
			},
			customStyle1:{
				type:Object,
				default:{}
			},
			customStyle11:{
				type:Object,
				default:{}
			},
			customStyle2:{
				type:Object,
				default:{}
			},
			customStyle3:{
				type:Object,
				default:{}
			},
		},
		data() {
			return {
				is_shensu:1,
				subDisabled:false,
				loading:false,
				afterSalesRecord2:{},
				afterSalesRecord3:{}
			}
		},
		mounted() {
			this.afterSalesRecord3=this.afterSalesRecord
		},
		methods:{
			communicates() {
				createC2CConversation(this.order.release_user.mobile, this)
			},
			shensu(){
				var that = this
				that.loading = false
				that.$u.api.order.afterSalesRecord({
					aftersales_id: that.order.orderInfo.aftersales_id,
					lang:that.lang
				}).then(result => {
					that.afterSalesRecord2 = result
					that.is_shensu=2
					that.loading = true
				})
			},
			shensu_action(e,data,res){
				var that = this
				that.afterSalesRecord3 = res
				that.is_shensu=3
			},
			approve(join_status){
				const that = this
				var json = {
					join_status: join_status,
					aftersales_id :that.order.orderInfo.aftersales_id,
					lang:that.lang
				}
				that.$u.api.order.approveAppeal(json).then(res => {
					uni.showModal({
						content: that.$t('操作成功'),
						showCancel: false,
						confirmText: this.$t('是'),
					})
					that.$emit('change','customer','approve')
				})
			}
		}
	}
</script>

